package com.autumn.config.api.vo;

import java.io.Serializable;
import java.util.Map;

import com.autumn.config.api.consts.ConfigureConsts.ConnectionTypeConsts;
import com.autumn.util.AutumnContextUtils;

/**
 * 应用数据源配置输出
 * 
 * @author 老码农
 *         <p>
 *         Description
 *         </p>
 * @date 2018-01-02 21:15:17
 */
public class ServiceDataSourceConfigureValue implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3292118892770497546L;

	private String targetServiceId;
	private String targetAppName;
	private String connectionName;
	private Integer connectionType;
	private transient String propertyContent;

	public String getTargetServiceId() {
		return targetServiceId;
	}

	public void setTargetServiceId(String targetServiceId) {
		this.targetServiceId = targetServiceId;
	}

	public String getTargetAppName() {
		return targetAppName;
	}

	public void setTargetAppName(String targetAppName) {
		this.targetAppName = targetAppName;
	}

	public String getConnectionName() {
		return connectionName;
	}

	public void setConnectionName(String connectionName) {
		this.connectionName = connectionName;
	}

	public Integer getConnectionType() {
		return connectionType;
	}

	public void setConnectionType(Integer connectionType) {
		this.connectionType = connectionType;
	}

	/**
	 * 获取连接类型名称
	 * 
	 * @return
	 */
	public String getConnectionTypeName() {
		return ConnectionTypeConsts.getName(this.getConnectionType());
	}

	public String getPropertyContent() {
		return propertyContent;
	}

	public void setPropertyContent(String propertyContent) {
		this.propertyContent = propertyContent;
		if (this.propertys != null) {
			this.propertys = null;
		}
	}

	private Map<String, Object> propertys = null;

	/**
	 * 获取属性 Map
	 * 
	 * @return
	 */
	public Map<String, Object> getPropertys() {
		if (this.propertys == null) {
			this.propertys = AutumnContextUtils.parseProperties(this.getPropertyContent(), false);
		}
		return this.propertys;
	}
}
